const router = require('koa-router')()
const controller = require('../controller')

router.get('/', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

router.get('/api/product', async (ctx, next) => {
  ctx.body = {
    title: 'product json'
  }
})
  .post("/api/addcar", controller.car.add)   // 添加汽车
  .get("/api/getinfo", controller.car.find)   // 查询汽车信息
  .get("/api/deletecar/:id", controller.car.delcar)  // 删除汽车信息 (有参数路由问题)
  .get("/api/getLunbo", controller.lunbo.find)
  .get("/api/getNewslist",controller.newslist.find)
  .get("/api/getNewsInfo/:id",controller.newsinfo.find)
  .get("/api/getComments/:id",controller.comment.find)
  .post("/api/addComments/:id",controller.comment.add)
  .get("/api/getimgcategory",controller.imgcategory.find)
  .get("/api/getimages/:cateid",controller.imglist.find)
  .get("/api/getimageinfo/:imgid",controller.imginfo.find)
  .get("/api/getthumimages/:imgid",controller.imgthum.find)
  .get("/api/getgoods",controller.goodslist.find)
  .get("/api/goods/getinfo/:id",controller.goodsinfo.find)
  .get("/api/goods/getdesc/:id",controller.goodsdesc.find)
  .get("/api/goods/getshopcarlist/:ids",controller.shopcarlist.find)
// .get("/api/deletecar", controller.car.delcar)  // 删除汽车信息 (有参数路由问题)

module.exports = router
